package com.example.springbootdemo.service;

import com.example.springbootdemo.base.BaseResult;
import com.example.springbootdemo.bean.User;
import com.example.springbootdemo.enums.ResultEnum;
import com.example.springbootdemo.mapper.UserMapper;
import com.example.springbootdemo.utils.ResultUtil;
import com.example.springbootdemo.utils.TokenUtil;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserSevice {

//    @Autowired
//    UserMapper mUserMapper;

    public BaseResult Login(User user) throws Exception {
//        User mUser = mUserMapper.selectByUsername(user.getUsername());
//        if (mUser != null) {
//            if (mUser.getPassword().equals(user.getPassword())) {
//                //登陆成功
//                return ResultUtil.success(TokenUtil.createToken(mUser.getId()));
//            } else {
//                //密码错误
//                return ResultUtil.failed(ResultEnum.ERROR_PASSWORD.getCode(), ResultEnum.ERROR_PASSWORD.getMessage());
//            }
//        } else {
//            //账号不存在
//            return ResultUtil.failed(ResultEnum.NO_ACCOUNT.getCode(), ResultEnum.NO_ACCOUNT.getMessage());
//        }
        return ResultUtil.success();
    }
}
